package com.sakura.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sakura.dao.ReplyMapper;

import com.sakura.po.BeComment;
import com.sakura.po.Reply;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("ReplyService")
public class ReplyServiceImpl implements ReplyService{
    @Autowired
    private ReplyMapper replyDao;
    @Override
    public PageInfo<Reply> getAllReply(Reply reply, int page, int limit){
        PageHelper.startPage(page,limit);
        List<Reply> list=replyDao.getAllReply(reply);
        PageInfo<Reply> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public void addReplySubmit(Reply reply) {
        replyDao.insert(reply);
    }

    @Override
    public void updateReplySubmit(Reply reply) {
        replyDao.updateByPrimaryKey(reply);
    }

    @Override
    public Reply queryReplyById(Integer id) {
        return replyDao.selectByPrimaryKey(id);
    }

    @Override
    public void deleteReplyByIds(List<String> ids) {
        for(String id:ids){
            replyDao.deleteByPrimaryKey(Integer.valueOf(id));
        }
    }
    @Override
    public List<Reply> getRlyCountByNum() {
        return replyDao.getRlyCountByNum();
    }
}
